using Ardalis.Specification;

namespace Domain.Todos.Specifications;

/// <summary>
/// 带分页的待办事项规约
/// </summary>
public sealed class TodosWithPaginationSpecification : Specification<TodoItem>
{
    public TodosWithPaginationSpecification(Guid userId, int pageNumber, int pageSize)
    {
        Query.Where(todo => todo.UserId == userId)
             .OrderByDescending(todo => todo.CreatedAt)
             .Skip((pageNumber - 1) * pageSize)
             .Take(pageSize);
    }
}